<template>
  <div class="shortmsg-博客配置-set gray-box top-redius border-bottom-gray">
    <div class="title">{{$t('sysManagement.thansferConfig')}}</div>
    <el-form
      ref="dataForm"
      label-width="180px"
      size="mini"
      class="set-form"
      label-position="left"
    >
      <el-form-item :label="$t('sysManagement.thansferAudit')" style="width:640px" >
        <el-switch v-model="audit"
                   active-value=true inactive-value=false
                   active-color="#13ce66"
                   inactive-color="#ff4949"
                   active-text="自动"
                   inactive-text="人工"
        ></el-switch>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <div class="default-btn" @click="dataFormSubmit()">{{$t('sysManagement.save')}}</div>
    </span>
  </div>
</template>

<script>
export default {
  data () {
    return {
      visible: false,
      audit: false
    }
  },
  mounted () {
    this.init()
  },
  methods: {
    init () {
      var that = this;
      that.$nextTick(() => {
        that.$http({
          url: that.$http.adornUrl('/sys/pconfig/info/' + 'TRANSFER_SWITCH_CONFIG'),
          method: 'get',
          params: that.$http.adornParams()
        }).then(({ data }) => {
          that.audit = data
          debugger
        })
      })
    },
    // 表单提交
    dataFormSubmit () {
      this.$http({
        url: this.$http.adornUrl('/sys/pconfig/save'),
        method: 'post',
        data: this.$http.adornData({
          'paramKey': 'TRANSFER_SWITCH_CONFIG',
          'paramValue': this.audit,
          'remark': this.$i18n.t('sysManagement.thansferAudit')
        })
      }).then(({ data }) => {
        if (data) {
          this.init()
        }
        this.$message({
          message: this.$i18n.t('publics.operation'),
          type: 'success',
          duration: 1500,
          onClose: () => {
            this.visible = false
            this.$emit('refreshDataList')
          }
        })
      })
    }
  }
}
</script>
